package com.example.admin.controller;

import com.example.admin.service.SensitiveService;
import com.usian.model.admin.dtos.SensitiveDto;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.common.enums.AppHttpCodeEnum;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/v1/sensitive")
@Api(tags = "敏感词管理接口")
@Slf4j
public class SensitiveController {


    @Autowired
    private SensitiveService sensitiveService;


    @PostMapping("/get_sensitive_by_name")
    public ResponseResult getSensitiveByName(@RequestBody SensitiveDto sensitiveDto) {
        log.info("根据名称查询敏感词，参数sensitiveDto:{}", sensitiveDto);
        if (sensitiveDto == null) {

            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_REQUIRE);
        }
        return ResponseResult.okResult(null);
    }


    @PostMapping("add_sensitive")
    public ResponseResult addSensitive(@RequestBody SensitiveDto sensitiveDto) {
        Integer i = sensitiveService.addSensitive(sensitiveDto);
        if (i > 0) {
            return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
        }
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);


    }


}
